home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
u_chk.arc
/
USERIS.C
< prev
next >
Wrap
Text File
|
1989-12-17
|
6KB
|
260 lines
/*
John T. McCann, NOVUSER Wizard SysOp, 70007,3430
1/5/89
Written in Turbo C v2.0
This program will, given a command line argument, verify a user's
login name on the current file server, ex:
USERIS JOHN
if JOHN is a valid LOGIN NAME (for a user) on the current file server
a DOS ERRORLEVEL of 0 is returned
if not valid, a DOS ERRORLEVEL of 1 is returned
if no command line arguement is entered 2 is returned
if not logged into any file servers (but the shell is loaded)
3 is returned
if the shell is not loaded 4 is returned
*/
#define inc "UserIs, (c)1989 Wizard Stuff"
#define Version 1.0
typedef union {
struct {
unsigned int Ax, Bx, Cx, Dx, Bp, Si, Di, Ds, Es, FLAGS;
} F;
struct {
unsigned char Al, Ah, Bl, Bh, Cl, Ch, Dl, Dh;
} H;
} Registers;
typedef struct {
unsigned char ah, al, bh, bl;
} Longs;
typedef struct {
char wh, wl;
} MyWord;
typedef struct {
MyWord Native;
char func; /* $36 for get object name */
Longs unique;/* Unique ID for the object */
} e336cl;
typedef struct {
MyWord Native;
Longs id; /* same id as above */
MyWord ObjTyp; /* type of object */
char Name[47];
} e336rp;
typedef struct {
MyWord Native;
char Func; /* $46 = get my bindery access level */
} chkcall;
typedef struct {
MyWord Native;
char Mask;
Longs id;
} chkrply;
typedef struct {
MyWord Native;
char Func; /* 55 for Search for Users */
Longs last; /* make it -1 */
MyWord ObjTyp; /* Search for users 0001 */
char ObjNml; /* 1 */
char ObjNme[47]; /* *, if search all is used */
} e33dcall;
typedef struct {
MyWord Native;
Longs Id;
MyWord ObjectType;
char PropName[47];
/* could add some space down here since I tell it the reply buffer
is 255 bytes long, but, that really isn't going to happen... */
} e33drply;
#if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
#define Seg(ptr) _DS
#define Ofs(ptr) (unsigned)(ptr)
#else
#define Ofs(fp) ((unsigned)(fp))
#define Seg(fp) ((unsigned)((unsigned long)(fp) >> 16))
#endif
#define MsDos intr
#define length(s) strlen(s)
Registers Regs;
chkcall cc;
chkrply cr;
e336cl nc;
e336rp nr;
e33dcall pc;
e33drply pr;
int a;
void UserI(argv)
char *argv[];
{
char PS[80]; /* just a string to hold the paramstr(1) variable */
/* NOTE I had used 1f on next line (last.ah), it is now ff, it is SUPPOSE to be ff, sorry
for any inconvenience this may cause, if you use 1f it will be a problem
with netware 386 */
pc.last.ah = 0xff; /* set the last object seen to -1 */
pc.last.al = 0xff;
pc.last.bh = 0xff;
pc.last.bl = 0xff;
pr.Native.wl = 0x00;
pr.Native.wh = 0xFF;/* set up reply buffer size, note it really isn't 255
bytes long, but neither is the possible reply... */
pc.Native.wl = 0x00;
pc.Native.wh = 0x8 + length(argv[1]); /* set up length of request buffer */
pc.Func = 0x37; /* scan bindery objects */
pc.ObjTyp.wh = 0;
pc.ObjTyp.wl = 1; /* 01 = user object type */
pc.ObjNml = length(argv[1]);
strcpy(PS, argv[1]);
for (a = 0; a <= (pc.ObjNml % 48); a++)
{
if ( (PS[a]>96) && (PS[a]<123) ) PS[a] = PS[a] - 32;
/* convert to Upper Case */
pc.ObjNme[a] = PS[a];
}
Regs.F.Ax = 0xE300;
Regs.F.Es = Seg(&pr);
Regs.F.Di = Ofs(&pr);
Regs.F.Ds = Seg(&pc);
Regs.F.Si = Ofs(&pc);
MsDos(33,&Regs);
if (Regs.H.Al == 0) exit(0);else exit(1);
}
/* of Proc UserI */
void Will_It_Run()
{
Regs.F.Ax = 0xE300;
cc.Native.wl = 0x00;
cc.Native.wh = 0x01;
cr.Native.wl = 0x00;
cr.Native.wh = 0xff;
cc.Func = 0x46;
cr.Mask = 0x00;
cr.id.al = 0x00;
cr.id.ah = 0x00;
cr.id.bl = 0x00;
cr.id.bh = 0x00;
Regs.F.Es = Seg(&cr);
Regs.F.Di = Ofs(&cr);
Regs.F.Ds = Seg(&cc);
Regs.F.Si = Ofs(&cc);
MsDos(33,&Regs);
if ((cr.id.al == 0x00) && (cr.id.ah == 0x00) && (cr.id.bl == 0x00) && (cr.id.bh == 0x00))
{
printf("%s\n",inc);
printf("This utility requires Advanced Netware to run.\n");
exit(4);
}
Regs.F.Ax = 0xE300;
nr.Native.wl = 0x00;
nr.Native.wh = 0xFF;
nc.Native.wl = 0x00;
nc.Native.wh = 0x05;
Regs.F.Es = Seg(&nr);
Regs.F.Di = Ofs(&nr);
Regs.F.Ds = Seg(&nc);
Regs.F.Si = Ofs(&nc);
nc.func = 0x36;
nc.unique.ah = cr.id.ah;
nc.unique.al = cr.id.al;
nc.unique.bh = cr.id.bh;
nc.unique.bl = cr.id.bl;
MsDos(33,&Regs);
if (Regs.H.Al != 0)
{
printf("%s\n",inc);
printf("This utility requires you to be logged into the network to run.\n");
exit(3);
}
}
/* of Will_it_Run */
main(argc,argv)
int argc;
char *argv[];
{
if (length(argv[1]) < 1)
{
printf("%s\n",inc);
printf("Usage: USERIS xxxxx where xxxxx is the username to check\n");
printf(" existence of on the current file server\n");
exit(2);
}
Will_It_Run();
UserI(argv);
}